import Vue from "vue";
import VueRouter from "vue-router";
//引入路由组件
import Login from "../pages/Login";
import Home from "../pages/Home";
import News from "../pages/Home/News";
import Music from "../pages/Home/Music";
import Games from "../pages/Home/Games";

Vue.use(VueRouter);

export default new VueRouter({
  routes: [
    {
      path: "/login",
      component: Login,
      name:"login"
    },
    {
        path:"/home",
        component:Home,
        // name:"home",
        children:[
          {path:"music/:id/:time?",component:Music,name:"music",props:true},
          {path:"news",component:News,name:"news"},
          {path: "games", component: Games, name: "games",
          //props第三种写法,props可以是一个函数,函数的参数是当前路由的$route路由对象
          props:(route)=>{
            return route.query
          }},
          {path:"",redirect:"/home/news"},
        ]
    },
    {path:"/",redirect:"/home"},
  ],
});
